# 6.8
import operator
from functools import reduce

print(u'%s %s' % (u'abc', 'abc'))

# 6.11
aList = list('foo')
print(aList)
aList[1] = 'l'
print(aList)

aList.append(['inner', 'list'])
print(aList)
print(aList[3][1])

del aList[3][1]
print(aList)

aList.remove('l')
print(aList)
aList.append('o')
aList.append('o')
print(aList)
aList.remove('o')
print(aList)

aList += [43, -12.34, [1, 'x'], -1.9 + 6j]
aList *= 2
print(aList)
aList = [i * 2 for i in aList]
print(aList)

# 6.13
fn = ['small', 'what', 'haier']
ln = ['brain', 'nail', 'foolish']
print([('%s %s' % (i, j)).title() for i, j in zip(fn, ln)])

a = [6, 4, 5, 8]
print(sum(a))
print(reduce(operator.add, a))
print(sum(a, 11))

# 6.14
print(dir(list))
print(dir([]))
aList = [45]
aList.insert(0, 'compact disc')
print(aList)
aList.append('long playing record')
print(aList)
aList.insert(2, '8-track tape')
print(aList)
print('cassette' in aList)
print('compact disc' in aList)
# TypeError: '<' not supported between instances of 'int' and 'str'
# aList.sort()
aList.reverse()
print(aList)

motd = []
motd.append('Msg of the day')
f = open('unicode.txt', 'r')
motd.extend(f)
f.close()
print(motd)
